﻿using System;
using System.Collections.Generic;

namespace BSPortal.Usercontrol
{
    public partial class LeftMenu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            var line = Common.GetLine();
            switch (line)
            {
                case 2:
                    {
                        LoadCommonCategory();
                    }
                    break;
                case 3:
                    {
                        LoadCommonCategory();
                    }
                    break;
                case 1:
                    {
                        LoadCommonCategory();
                        var control1 = (WriterCategory)LoadControl("WriterCategory.ascx");
                        catgoryPlaceHolder.Controls.Add(control1);
                    }
                    break;
                default:
                    leftDiv.Visible = false;
                    break;
            }
        }

        protected void LoadCommonCategory()
        {
            MainService service = new MainService();
            List<Category> listLineCategory = service.GetListChildCategoryByParent(Common.GetLine());
            foreach (var category in listLineCategory)
            {
                var control = (CategoryMenu) LoadControl("CategoryMenu.ascx");
                control.CategoryId = category.CategoryId;
                catgoryPlaceHolder.Controls.Add(control);
            }

            var control1 = (Publisher)LoadControl("Publisher.ascx");
            catgoryPlaceHolder.Controls.Add(control1);
        }
    }
}